<?php

namespace App\Admin\Controllers;

use App\Models\Complaint;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;

class ComplaintController extends Controller
{
    use HasResourceActions;

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index(Content $content)
    {
        return $content
            ->header('投诉管理')
            ->description('description')
            ->body($this->grid());
    }

    /**
     * Edit interface.
     *
     * @param mixed $id
     * @param Content $content
     * @return Content
     */
    public function edit($id, Content $content)
    {
        return $content
            ->header('编辑投诉')
            ->description('description')
            ->body($this->form()->edit($id));
    }
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Complaint);
        $grid->disableCreateButton();
        $grid->disableExport();
        $grid->actions(function ($actions) {
            $actions->disableEdit();
            $actions->disableView();
        });
        $grid->id('ID');
        $grid->type()->badge();
        $grid->columns('content','username','iphone');
        $grid->gender()->display(function($gender){
            return $gender==0?'先生':'女士';
        });
        $grid->pic()->image('',50,50);
        $grid->wxuser_id()->badge();
        $grid->status()->radio([
            1 => '已处理',
            2 => '处理中',
            3 => '待处理'
        ]);
        return $grid;
    }
    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Complaint);
        $form->radio('status');
        return $form;
    }

}
